home *** CD-ROM | disk | FTP | other *** search
- Path: chronicle.mti.sgi.com!austern
- From: Rich Paul <rpaul@trcinc.com>
- Newsgroups: comp.std.c++
- Subject: Re: A couple of questions about strings
- Date: 26 Mar 1996 10:58:31 PST
- Organization: Technical Resource Connection
- Approved: austern@isolde.mti.sgi.com
- Message-ID: <31580FC6.1A61@trcinc.com>
- References: <1278@dawes.win.net>
- NNTP-Posting-Host: isolde.mti.sgi.com
- X-Original-Date: Tue, 26 Mar 1996 10:39:50 -0500
- X-Mailer: Mozilla 2.0 (WinNT; I)
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBVAwUBMVg+1Uy4NqrwXLNJAQHObwIAjeTlyFTWYhG3qlEc+/LEQKTgU2aK6dFf
- ZDsJKlz5cUmdI0DdPp4g/Q2WG2gTxAWReUJZE84FBolUyrgwadcU3A==
- =r72p
- Originator: austern@isolde.mti.sgi.com
-
- Beman Dawes wrote:
- >
- >
- > >a) Why does basic_string::copy() not also copy an ending '\0'? If
- > >there's some sort of good reason, why wasn't a function added that did
- > >this (perhaps basic_string::copy_null() or something)? I must say, it
- > >is very inconvenient to copy a string to a C-style array of chars with
- > >the current string class.
- >
- > There is such a function - it is called c_str().
-
- well, to be equivilent, it would really be:
-
- strncpy ( buffer, string::c_str(), x );
- buffer[x] = 0; // only if strlen(buffer > x), but it's not safe
- // to check that way, since strlening a non-termed
- // char[] is a bad thing
- ---
- [ comp.std.c++ is moderated. To submit articles: Try just posting with your
- newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
- comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
- Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
- Comments? mailto:std-c++-request@ncar.ucar.edu
- ]
-